package com.wpl.controller;

import com.wpl.bean.Workorder;
import com.wpl.common.WebResponse;
import com.wpl.service.IOrderDetailService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 工单详情
 */
@RestController
@RequestMapping("/orderDetail/")
public class OrderDetailController {

    @Resource
    private IOrderDetailService orderDetailService;

    /**
     * 客户信息
     * @param id
     * @return
     */
    @PostMapping("/customer")
    public WebResponse getCustomerById(Integer id){
        Workorder customer = orderDetailService.getCustomerById(id);
        if (customer != null){
            return WebResponse.success(customer);
        }else {
            return WebResponse.failed();
        }
    }

    @PostMapping("/info")
    public WebResponse getInfoById(Integer id){
        Workorder info = orderDetailService.getInfoById(id);
        if (info != null) {
            return WebResponse.success(info);
        }else {
            return WebResponse.failed();
        }
    }

    /**
     * 工单信息
     * @param id
     * @return
     */
    @PostMapping("/order")
    public WebResponse getOrderById(Integer id) {
        Workorder workorder = orderDetailService.getWorkorderById(id);
        if (workorder != null){
            return WebResponse.success(workorder);

        }else {
            return WebResponse.failed();
        }
    }

}
